package io.gitee.caoxiaoyu97.log4j.defender;

import io.gitee.caoxiaoyu97.log4j.defender.constants.DefenderConstants;
import io.gitee.caoxiaoyu97.log4j.defender.properties.DefenderProperties;
import io.gitee.caoxiaoyu97.log4j.defender.provider.LogDefenderProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ConditionalOnProperty(name = {DefenderConstants.CXY_LOG_DEFENDER_ENABLE}, havingValue = "true")
@EnableConfigurationProperties({DefenderProperties.class})
@Configuration
public class LogDefenderAutoConfiguration {
    @Bean
    public LogDefenderProvider logDefenderProvider(DefenderProperties properties) {
        return LogDefenderProvider.getInstance().init(properties);
    }
}
